﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QLThuVien
{
    class NgonNgu
    {
        string mangonngu, ngonngu;
        public NgonNgu() { }
        public NgonNgu(string mangonngu, string ngonngu)
        {
            this.mangonngu = mangonngu;
            this.ngonngu = ngonngu;
        }

        public void set_mangonngu(string mangonngu)
        {
            this.mangonngu = mangonngu;
        }

        public void set_ngonngu(string ngonngu)
        {
            this.ngonngu = ngonngu;
        }

        public bool taomoi()        
        {
            Truyxuatdulieu txdl=new Truyxuatdulieu();
            if (txdl.thucthitruyvan("insert into ngonngu values('" + mangonngu + "',N'" + ngonngu + "')") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else 
            {
                KetNoi.closeconnect();
                return false;
            }
        }

        public bool update()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("update ngonngu set tennn=N'" + mangonngu + "' where mann='" + ngonngu + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else 
            {
                KetNoi.closeconnect();
                return false;
            }
        }

        public bool xoa()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("delete from ngonngu where mann='" + mangonngu + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }
    }
}
